﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Handrise.BasicModal.Serialization;

namespace Handrise.CDCable.Business
{
    /// <summary>
    /// 缺陷服务
    /// </summary>
    public class FlawService
    {
        private ServerExchange serverExchange = new ServerExchange();
        
        /// <summary>
        /// 上传缺陷
        /// </summary>
        /// <param name="flawsBuffer">缺陷的序列化流</param>
        /// <returns></returns>
        public bool UploadFlaws(string userName,byte[] flawsBuffer)
        {

            CompactFormatterPlus cfp = new CompactFormatterPlus();
            List<Flaw> flaws = (List<Flaw>)cfp.Deserialize(flawsBuffer);

            string entitysXML = CommonFunction.GetXMLFromEnitys<Flaw>((List<Flaw>)flaws, typeof(Flaw));

            string receiveData = serverExchange.UploadFlaws(userName, entitysXML);

            return CommonFunction.ReturnDataIsOk(receiveData); ;

        }
    }
}
